<template>
	<view class="majorCon">
		<view>
			<input class="userinfoCla" type="text" v-model="TeleP" placeholder="请输入手机号或邮箱"/>
		</view>
		<view class="BelowCla">
			<input type="number" v-model="verifi" class="userinfoCla" placeholder="请输入验证码"/>
			<button type="primary"  class="bntCla" @click="sendVis">{{TipsCon}}</button>
		</view>
		<view>
			<button type="primary" style="width: 600rpx;background: #FF7300;" @tap="registerFun">下一步</button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				TeleP: "",
				verifi: "",
				TipsCon: "点击获取验证码"
			}
		},
		
		methods: {
			sendVis() {
				if(this.TeleP === "" || !(/^1[3|4|5|8][0-9]\d{4,8}$/.test(this.TeleP))) {
					uni.showToast({
						 title: "请检查手机号码",
						 icon: "none"
					})
				}else {
					this.$myRequest({
						url: "/sms/send",
						data: {
							mobile: this.TeleP
						}
					}).then((res) => {
						if(res.code == 0) {
							uni.showToast({
								title: "发送成功"
							})
							this.countDown()
						}
					})
				}
			},
			
			countDown() {
				let num = 60
				const time = setInterval(() => {
						num--
						this.TipsCon = num + "s"
						if(num === 0){
							clearInterval(time)
							this.TipsCon = "点击获取验证码"
						}
					},1000)
			},
			
			registerFun() {
				if(this.TeleP === "" || this.verifi === "" ) {
					uni.showToast({
						title: "请检查信息",
						icon: "none"
					})
				}else {
					this.$myRequest({
						url: "/user/login",
						methed: "post",
						header: {
							'content-type' : 'applicatin/json'
						},
						data: {
							login_name: Number(this.TeleP),
							platform: "wx",
							login_type: 2,
							is_teach_paypal: true,
							verification_code: Number(this.verifi) 
						}
					}).then((res) => {
						if(res.code == 0){
							try {
								uni.setStorageSync('userif_list', res.data.userInfoEntity);
								uni.setStorageSync('user_token', res.data.userToken);
							} catch (e) {}
							uni.navigateTo({
								url: "/pages/Other/LiveinStructor/LiveinStructor"
							})
						}else {
							uni.showToast({
								title: res.message,
								icon: "none"
							})
						}
					})
				}
			}
		},
		
		onLoad() {
			
		}
	}
</script>
<style lang="scss" scoped>
	.majorCon {
		display: flex;
		flex-direction: column;
		align-items: center;
		.BelowCla {
			position: relative;
			.bntCla {
				width: 200rpx;
				height: 80rpx;
				background: #FF7300;
				position: absolute;
				top: 40rpx;
				left: 400rpx;
				font-size: 20rpx;
				box-sizing: border-box;
				line-height: 80rpx;
				z-index: 1212;
			}
		}
		.userinfoCla {
			height: 80rpx;
			width: 600rpx;
			border: 1rpx solid #FF7300;
			margin: 40rpx 0;
			box-sizing: border-box;
			padding: 0 40rpx;
			font-size: 28rpx;
			background: #FFFFFF;
			border-radius: 10rpx;
		}
	}
</style>